<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
</head>

<body>


    <script>

        // 对象
        // var obj = {}
        // 添加属性
        // obj.width = "100px";
        // 添加方法
        // obj.foo = function(){
        //     console.log("test");
        // }
        // obj.foo();

        // 构造函数(父类)
        function Person(name){
            this.name = name;
            this.age = 22;
            this.sex ="男";
            this.tel = "1358888999";
            this.email = "12312@qq.com"
        }
        Person.prototype.say = function(){
            console.log("hello ",this.name);
        }
        var p1 = new Person();
        // console.log(p1);

        // 构造函数 (子类)  
        function Student(){
            // 继承(得到)父类的属性
            Person.apply(this,["小明"]);
            // Person.call(this,"小红");
            // Person.bind(this)("小名");
        }
        // 设置原型
        Student.prototype = {
            constructor: Student ,
            say: p1.say
        }
        // 创建子类的实例
        var s1 = new Student();
        console.log(s1);
        s1.say();// 子类的实例调用父类的方法

      




    </script>
</body>

</html>